package com.kx.test;

import com.kx.my02.SomeService;
import com.kx.my02.Student;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest02 {
    @Test
    public void test() {
        String config = "applicationContext.xml";
        ApplicationContext ctx = new ClassPathXmlApplicationContext(config);
        //从容器中获取目标对象
        SomeService proxy = (SomeService) ctx.getBean("someService");
        //通过代理对象执行方法，实现目标方法执行时，增强了功能
        String str = proxy.doOther("zhangsan", 19);
        System.out.println("str===="+str);
    }
    @Test
    public void test2() {
        String config = "applicationContext.xml";
        ApplicationContext ctx = new ClassPathXmlApplicationContext(config);
        //从容器中获取目标对象
        SomeService proxy = (SomeService) ctx.getBean("someService");
        //通过代理对象执行方法，实现目标方法执行时，增强了功能
        Student student = proxy.doOther2("zhangsan", 19);
        System.out.println("student===="+student);
    }
}
